# import threading
# import time
# import re
# from urllib.parse import urlencode
# import urllib.parse
# import requests
# # for num in range(5):
import requests
import json
from flask import Flask, request


# def check():
#     # 默认返回内容
#     return_dict = {'return_code': '200', 'return_info': '成功', 'result': False}
#     # 判断入参是否为空
#     if request.args is None:
#         return_dict['return_code'] = '5004'
#         return_dict['return_info'] = '请求参数为空'
#         return json.dumps(return_dict, ensure_ascii=False)
#     # 获取传入的params参数
#     get_data = request.args.to_dict()
#     username = get_data.get('username')
#     password = get_data.get('password')
#     # 对参数进行操作
#     return_dict['result'] = tt(username, password)
#
#     return json.dumps(return_dict, ensure_ascii=False)
#
#
# # 功能函数
# def tt(name, age):
#     start_response('200 OK', [('Content-Type', 'text/plain')])
#     result = 'This is a python application!'
#     return [result.encode()]
#
#
# if __name__ == "__main__":
#     app.run(debug=True)
# url = '/user/login/index'
# data = {
#             'check_code': ,
#             'time': time,
#             'sn': sn,
#             'version': version
#         }
#     timestamp = time.time()
#     a = str(timestamp) + 'CMJF_getSignInfo'
#     # print(a)
#     md5 = hashlib.md5()
#     md5.update(a.encode('utf-8'))
#     md5 = md5.hexdigest()
#     t = test(timestamp, md5)


# #
# # 	def run(name):
# # 		print(name, "线程执行了")
# # 		time.sleep(5)
# #
# #
# # 	# 程序执行时，程序本身就是一个线程，叫主线程
# # 	# 手动创建的线程，叫子线程
# # 	# 主线程的执行中不会等待子线程执行完毕，就会直接执行后面的代码
# # 	# 创建线程
# #
# # 	t1 = threading.Thread(target=run, args=("t1",))
# # 	t2 = threading.Thread(target=run, args=("t2",))
# # 	t1.start()  # 启动线程
# # 	t2.start()
# # 	t1.join()  # 等待子线程执行完毕之后再执行主线程内容
# # 	t2.join()
# #
# # 	print("执行完毕")
# name = str(input('请输入职位名称：'))
# city = str(input('请输入求职城市：'))
# jobName = urllib.parse.quote(name)
# jobCity = urllib.parse.quote(city)
# url = 'https://zhaopin.baidu.com/quanzhi?query=' + jobName + '&city=' + jobCity
# r = requests.get(url)
# r.encoding = 'utf-8'
# print(r.text)
#
# # url2 = 'https://zhaopin.baidu.com/quanzhi?query=%E6%B5%8B%E8%AF%95&city=%E6%B7%B1%E5%9C%B3'
# # if url1 == url2:
# #     print('1')
# # else:
# #     print('2')
# # info = re.findall('<div class="el">(.*?)</div>', re.S, )
# # print(url1)
# # print(url2)
import requests
import json
# import pandas
# def jobDetails(url):
#     #result = {}
#     joblist = []
#     res = requests.get(url)
#     jd = json.loads(res.text)
#     jobinfo = jd['data']['main']['data']['disp_data']
#     for ent in jobinfo:
#         result = {}
#         #result['WorkCity'] = ent['city']
#         result['ApplicantSex'] = ent['sex']
#         result['JobName'] = ent['name'].lstrip('\t ')
#         #result['JobType'] = ent['jobfirstclass']
#         result['JobSalary'] = ent['ori_salary']
#         result['JobEducation'] = ent['education']
#         result['JobExperience'] = ent['experience']
#         result['RecruitNumber'] = ent['number']
#         result['RecruitStarDate'] = ent['startdate']
#         result['RecuitEndDate'] = ent['enddate']
#         #result['jobduty'] = ent['description'].split('。')[0]
#         result['jobduty'] = ent['description']
#         #result['JobRequirement'] = ent['description'].split('。')[1].lstrip('任职资格：')
#         result['RecruitSource'] = ent['source']
#         result['RecruitUrl'] = ent['url']
#         result['CompanyName'] = ent['officialname']
#         result['CompanyNature'] = ent['employertype']
#         #result['CompanySize'] = ent['size']
#         #result['CompanyType'] = ent['industry']
#         joblist.append(result)
#     return joblist
#     #print(joblist)
#     #return df.to_excel('job.xlsx')
#
# url = 'http://zhaopin.baidu.com/api/quanzhiasync?query=%E5%82%AC%E6%94%B6%E5%91%98%E6%8B%9B%E8%81%98&sort_type=1&city=%E6%9D%AD%E5%B7%9E&detailmode=close&rn=20&pn={}'
# job_total = []
# for i in range(0,60,20):
#     recruiturl = url.format(i)
#     job_total.extend(jobDetails(recruiturl))
# df = pandas.DataFrame(job_total)
# df.to_excel('job_hangzhou.xlsx')
# #print(job)
